package com.wondedDream.controller.admin;

import com.wondedDream.model.UserMockExamRecord;
import com.wondedDream.service.UserMockExamRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController(value = "adminUserMockExamRecordController")
@RequestMapping("/api/userMockExamRecords")
@Api(description = "管理端-用户模考信息")
public class UserMockExamRecordController {
    @Autowired
    private UserMockExamRecordService userMockExamRecordService;

    // 保存用户模考记录
    @PostMapping("/")
    @ApiOperation(value = "保存用户模考记录")
    public UserMockExamRecord saveUserMockExamRecord(@RequestBody UserMockExamRecord record) {
        return userMockExamRecordService.saveUserMockExamRecord(record);
    }

    // 根据记录 ID 获取用户模考记录
    @GetMapping("/{recordId}")
    @ApiOperation(value = "根据记录 ID 获取用户模考记录")
    public UserMockExamRecord getUserMockExamRecord(@PathVariable Integer recordId) {
        return userMockExamRecordService.getUserMockExamRecordById(recordId);
    }

    // 根据用户 ID 获取用户的所有模考记录
    @GetMapping("/byUser/{userId}")
    @ApiOperation(value = "根据用户 ID 获取用户的所有模考记录")
    public List<UserMockExamRecord> getUserMockExamRecordsByUser(@PathVariable Integer userId) {
        return userMockExamRecordService.getUserMockExamRecordsByUser(userId);
    }

    // 根据模考 ID 获取用户的所有模考记录
    @GetMapping("/byMockExam/{mockExamId}")
    @ApiOperation(value = "根据模考 ID 获取用户的所有模考记录")
    public List<UserMockExamRecord> getUserMockExamRecordsByMockExam(@PathVariable Integer mockExamId) {
        return userMockExamRecordService.getUserMockExamRecordsByMockExam(mockExamId);
    }

    // 获取所有用户模考记录
    @GetMapping("/")
    @ApiOperation(value = "获取所有用户模考记录")
    public List<UserMockExamRecord> getAllUserMockExamRecords() {
        return userMockExamRecordService.getAllUserMockExamRecords();
    }

    // 删除用户模考记录
    @DeleteMapping("/{recordId}")
    @ApiOperation(value = "删除用户模考记录")
    public void deleteUserMockExamRecord(@PathVariable Integer recordId) {
        userMockExamRecordService.deleteUserMockExamRecord(recordId);
    }

    // 更新用户模考记录
    @PutMapping("/{recordId}")
    @ApiOperation(value = "更新用户模考记录")
    public UserMockExamRecord updateUserMockExamRecord(@PathVariable Integer recordId, @RequestBody UserMockExamRecord record) {
        record.setId(recordId);
        return userMockExamRecordService.updateUserMockExamRecord(record);
    }
}